<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initModuleAutoload() {
        $modelLoader = new Zend_Application_Module_Autoloader(array(
                'namespace' => '',
                'basePath' => APPLICATION_PATH . '/modules/default')
                );
        $modelLoader->addResourceType('form', 'forms', 'Form')
               ->addResourceType('model', 'models', 'Model')
               ->addResourceType('dbtable', 'models/DbTable', 'Model_DbTable');

        return $modelLoader; 
    }  

   protected function _initAutoload() {
        // cache zend classes
   // cache zend classes
        $classFileIncCache = APPLICATION_PATH . '/pluginLoaderCache.php';
       if (file_exists($classFileIncCache)) {
           include_once $classFileIncCache;
       }
       Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
        
    }
            
	protected function _initConfig(){
        $config = new Zend_Config($this->getOptions());
        Zend_Registry::set('config', $config);
        return $config;
    }

	function _initViewHelpers() {
		$this->bootstrap('layout');
		$layout = $this->getResource('layout');
		$view = $layout->getView();
        
        $view->headTitle('Filmix searcher');

		$view->setHelperPath(APPLICATION_PATH.'/modules/default/views/helpers');

	}

/**   protected function _initSetTranlsation(){
        $translate = new Zend_Translate(array(
											'adapter' => 'ini',
											'logUntranslated' => false, // remove this on run
											'content' => APPLICATION_PATH."/langs/ru.ini",
											'locale'  => 'ru'));
                                            
        $translate->getAdapter()->addTranslation(
            array(
                'content' => APPLICATION_PATH."/langs/en.ini",
                'locale' => 'en'
            ));                                            
                 
       // $translate->getAdapter()->setLocale('ru');                           
        Zend_Registry::set('Zend_Translate', $translate);
		Zend_Form::setDefaultTranslator($translate);
   }
   
 */
   

    protected function _initNavigationXml(){

    	$this->bootstrap('layout');
    	$layout = $this->getResource('layout');
    	$view = $layout->getView();

        $config = new Zend_Config_Xml(APPLICATION_PATH.'/main_menu.xml');
		$n = new Zend_Navigation($config);

		$config = new Zend_Config_Xml(APPLICATION_PATH.'/login_menu.xml');
		$l = new Zend_Navigation($config);

		$config = new Zend_Config_Xml(APPLICATION_PATH.'/admin_menu.xml');
		$a = new Zend_Navigation($config);

    	$view->navigation($n);
    	$view->main_menu = $n;
    	$view->login_menu = $l;
    	$view->admin_menu = $a;
    	return $n;
    }
    
    protected function _initZFDebug(){
        return true;
    	$autoloader = Zend_Loader_Autoloader::getInstance();
    	$autoloader->registerNamespace('ZFDebug');
    
    
        $options = array(
            'plugins' => array(
                'Variables',
                'File' => array('base_path' => APPLICATION_PATH),
                'Memory',
                'Time',
                'Registry',
                'Exception',
                'Database',
                'Html',
            )
        );
    
        // ��������� ������� ��� �������� ���� ������
        if ($this->hasPluginResource('db')) {
            $this->bootstrap('db');
            $db = $this->getPluginResource('db')->getDbAdapter();
            $options['plugins']['Database']['adapter'] = $db;
        }

        // ��������� ������� ��� ����
        if ($this->hasPluginResource('cache')) {
            $this->bootstrap('cache');
            $cache = $this-getPluginResource('cache')->getDbAdapter();
            $options['plugins']['Cache']['backend'] = $cache->getBackend();
        }

      	//include(APPLICATION_PATH.'/../library/ZFDebug/Controller/Plugin/Debug.php');
        $debug = new ZFDebug_Controller_Plugin_Debug($options);
    
        $this->bootstrap('frontController');
        $frontController = $this->getResource('frontController');
        $frontController->registerPlugin($debug); 
    }
    
    protected function _initUser() {
        $user = new Model_User_Auth();
        Zend_Registry::set('User', $user);
    }
    


}